﻿using System;
using System.Reflection;
using Microsoft.WindowsAPICodePack.Taskbar;

namespace HeritageAcademy.Window
{
    public static class Taskbar
    {
        private static JumpList JumpList { get; set; }

        public static void PrepareTaskbar()
        {
            try
            {
                if (TaskbarManager.IsPlatformSupported)
                {
                    string systemFolder = Environment.GetFolderPath(Environment.SpecialFolder.System);
                    JumpList = JumpList.CreateJumpList();

                    JumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;

                    JumpList.AddUserTasks(
                        new JumpListLink(Assembly.GetEntryAssembly().Location, "Перейти в библиотеку")
                        {
                            Arguments = "/library"
                        });

                    JumpList.AddUserTasks(
                        new JumpListLink("%SYSTEMROOT%\\explorer.exe", "Получить новые курсы")
                        {
                            Arguments = "http://www.heritage-academy.ru/courses"
                        });

                    JumpList.Refresh();
                }
            }
            catch
            { 
                // catch rare COM exceptions
            }
        }

        public static void AddToRecent(string destination)
        {
            if (TaskbarManager.IsPlatformSupported)
            {
                JumpList.AddToRecent(destination);
            }
        }

    }
}
